package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonTurnipBillBoardItemBean;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;

import java.util.List;

/**
 * Created by shiweiwei on 2017/12/7.
 */

public class TurnipBillBoardAdapter extends CommonRecycleViewAdapter<CartoonTurnipBillBoardItemBean> {
    public TurnipBillBoardAdapter(Context mContext, List<CartoonTurnipBillBoardItemBean> itemDatas) {
        super(mContext, R.layout.turnip_billboard_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, CartoonTurnipBillBoardItemBean item, int position) {

        ImageView turnip_rank = customViewHold.getView(R.id.turnip_rank);
        TextView bill_board_num = customViewHold.getView(R.id.bill_board_num);
        SimpleDraweeView head_icon = customViewHold.getView(R.id.head_icon);
        TextView nick_name = customViewHold.getView(R.id.nick_name);
        TextView turnip_num = customViewHold.getView(R.id.turnip_num);
        TextView class_name = customViewHold.getView(R.id.class_name);
        head_icon.setImageURI(item.getCustomerImgurl());

        switch (position) {
            case 0:
                turnip_rank.setImageResource(R.mipmap.gold_turnip);
                turnip_rank.setVisibility(View.VISIBLE);
                break;
            case 1:
                turnip_rank.setImageResource(R.mipmap.silver_turnip);
                turnip_rank.setVisibility(View.VISIBLE);
                break;
            case 2:
                turnip_rank.setImageResource(R.mipmap.copper_turnip);
                turnip_rank.setVisibility(View.VISIBLE);
                break;
            default:
                turnip_rank.setVisibility(View.GONE);
                bill_board_num.setVisibility(View.VISIBLE);
                int rank = position + 1;
                bill_board_num.setText(String.valueOf(rank));
                break;
        }

        if(!TextUtils.isEmpty(item.getStudentName())){
            nick_name.setText(item.getStudentName());
        }

        if (!TextUtils.isEmpty(item.getClassName())){
            class_name.setText(item.getClassName());
        }

        if (!TextUtils.isEmpty(String.valueOf(Double.valueOf(item.getRadishCount()).intValue()))){
            turnip_num.setText(String.valueOf(Double.valueOf(item.getRadishCount()).intValue()));
        }

    }
}
